Beginners Programming Series IX

Part 1 - Introduction

© 2004, Brad Moore

author contact:

http://www.freewebz.com/lb-connection


Welcome Back...

...to another Beginner Series. This is the ninth in the series of installments covering beginning programming with Liberty Basic. The series is now a year in the making, and we still have a ways to go.

At this point, if you have been following along, you should be finding yourself more comfortable with the basic techniques of programming applied to Liberty Basic. I have heard from many people who have enjoyed this series and the jump start it has given them in programming. I hope you too are benefiting.

A key to getting the most from this series is doing the challenges that follow each installment. As you will remember from the last issue, we presented a calculator for the project this time. Our aim is to spend some time explaining form layout and the use of the Liberty Basic tool "FreeForm".

We are going to break from tradition with this installment, forgoing the glossary. We will also be discussing our code in larger blocks, with a little less line by line detail. So lets get into it.

As you will recall we introduced a calculator as our next challenge. I am sure most readers are familiar with the common household handheld calculator. It has buttons for numerals 0 through 9, for addition, subtraction, division, multiplication as well as equals. Most have on/off, clear, and clear entry functions also. That is a lot of buttons!

We could lay all these out using trial and error in the editor, trying to set the button heights, widths and locations - but that is a lot of work. Liberty Basic offers a native form layout tool to simplify the process. It is called FreeForm, and remarkably it is written in Liberty Basic itself!

Introducing FreeForm

FreeForm is available from the run menu of the Liberty Basic editor:

Once started, FreeForm has two toolbars that offer a simple single click access to most of the layout programs features:

FreeForm also presents an initial open form to begin working with upon opening. Remember the primary function of FreeForm is the layout of windows (usually called forms) and the generation of the Liberty Basic code to create the form. This type of tool is used as a major component of what is often called Rapid Application Development or RAD. It allows us to simply and effectively create a user interface in "draw mode" if you will.

The topmost toolbar in FreeForm offers shortcuts to the programs most used menu items. Things like New Form, Save, Copy, Paste, Run and so forth. One of the things I like to do when I first start FreeForm is go to the Options -> Program Settings (in the menus) and then enable Tooltips.

The major tools used to create the form layout are in the second toolbar. This is the controls toolbar. Each of them is used to create a specific windows control on the form. Many of these controls we have not yet discussed in this series. Each is briefly introduced here:

Label - The label control allows placement of text on the form. The user can not interact with it.

Textbox - The textbox control is an open field in which the user is permitted to type text.

Command Button - This is the basic windows button. It allows your user to interact with the program. These usually have a text caption that describes the button's function.

Bitmap Button - This is like the Command Button, however you are allowed to assign a bitmap graphic to be displayed on top of the button.

Listbox - The listbox control is a multiline field that usually has several values that the user may choose from. The user is not permitted to enter text into a listbox.

Combobox - The combobox is similar to the listbox in the way it handles lists and displays lists for the user to choose from. The combobox appears as a simple field that can be activated causing it to drop down showing the list of values it contains. The user may also enter text into the field of the combobox.

Radiobutton - The radiobutton control is often combined with the groupbox control to produce lists of options that can be toggled on and off by the user. The radiobutton is a binary switch which can either be set or reset.

Checkbox - The checkbox control is similar to the radiobutton, however it is usually used in a situation where one or more will be checked. When used in a groupbox they do not operate exclusively as the radiobutton does.

Groupbox - The groupbox control is often used for visual clarity in grouping similar controls. It is essential in the operation of the radiobutton causing all radiobuttons enclosed in the groupbox to act as a group - allowing only one to be set, resetting others automatically.

TextEditor - The texteditor control is a general purpose multiline text editor widget that offers cut and paste, text selection and other advanced features. It comes with its own edit menu which includes integrated cut and paste functions.

Graphicbox - The graphicbox is a special widget that has a defined area where graphic operations can be performed. We examined these at length in installment 8.

Using FreeForm

As I mentioned before, when FreeForm opens up it presents an initial blank form that can be used for your form layout project. Clicking on one of the tools in the controls menubar causes a control of that type to be placed on the form.

Some controls (such as the Command Button) have required components (such as Caption) which you may be prompted for when placing the control, as shown here:

Once the control is placed on the form it can be moved around and resized. Each control has resizing handles (little black square blocks) that can be grabbed with the mouse cursor and dragged to the size desired:

Clicking in the middle of the control and dragging will allow you to reposition the control.

Each control, and the form as well, have a set of properties that can be viewed and modified. As you design your form you will want to check these, and probably change some of them. Access the properties by double clicking the control, pressing Ctrl-I key sequence, or by selecting Control -> Properties from the menu.

Some of the properties you should consider changing are Caption, Control Extension (.ext), Branch, and sometimes ToolTips if your program is going to have tooltips.

Move on to the next part: Creating the calculator.